using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;

namespace sCicero
{

    public class scicero
    {
        private string m_sThisPath;
        private FileHandler m_oFileHandler;
        private ObjectWrapper m_oObjectWrapper;
        private XPathDocument m_oXpathDoc;
        private XPathDocument m_oXpathLangDoc;
        private xml m_Xml = null;
        private Event m_Event = null;
        private Data m_Data = null;
        private Students m_Students = null;
        private Classes m_Classes = null;
        private Periods m_Periods = null;
        private User m_User = null;
        private Subjects m_Subjects = null;
        private Tests m_Tests = null;
        private Grades m_Grades= null;
        private Results m_Results = null;
        private crc m_Crc = null;
        private Documents m_Documents = null;
        private DocumentLink m_DocumentLink = null;
        private Templates m_Templates = null;
        private pdf m_pdf = null;
        private word m_word = null;
        private Tree m_tree = null;
        private WorkAreas m_WorkAreas = null;

        public scicero(ref Data oData)
        {
            m_Data = oData;
            m_sThisPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Substring(6);
        }

        public static string ThisPath
        {
            get
            {
                return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Substring(6) + "\\";
            }
        }

        

        //todo: real returnvalues
        public bool ClearData()
        {
            m_Data.InitData(true);
            return true;
        }

        public FileHandler FileHandler
        {
            get
            {
                if (m_oFileHandler == null)
                    m_oFileHandler = new FileHandler(ref m_Data);
                return m_oFileHandler;
            }
        }

        public ObjectWrapper ObjectWrapper
        {
            get
            {
                if (m_oObjectWrapper == null)
                    m_oObjectWrapper = new ObjectWrapper(ref m_Data);
                return m_oObjectWrapper;
            }
        }

        public Tree Tree
        {
            get
            {
                if (m_tree == null)
                    m_tree = new Tree(ref m_Data);
                return m_tree;
            }
        }


        public word word
        {
            get
            {
                if (m_word == null)
                    m_word = new word(ref m_Data);
                return m_word;
            }
        }

        public pdf pdf
        {
            get
            {
                if (m_pdf == null)
                    m_pdf = new pdf(ref m_Data);
                return m_pdf;
            }
        }

        public Templates Templates
        {
            get
            {
                if (m_Templates == null)
                    m_Templates = new Templates(ref m_Data);
                return m_Templates;
            }
        }


        public DocumentLink DocumentLink
        {
            get
            {
                if (m_DocumentLink == null)
                    m_DocumentLink = new DocumentLink(ref m_Data);
                return m_DocumentLink;
            }
        }

        public Documents Documents
        {
            get
            {
                if (m_Documents == null)
                    m_Documents = new Documents(ref m_Data);
                return m_Documents;
            }
        }

        public Results Results
        {
            get
            {
                if (m_Results == null)
                    m_Results = new Results(ref m_Data);
                return m_Results;
            }
        }


        public crc crc
        {
            get
            {
                if (m_Crc == null)
                    m_Crc = new crc();
                return m_Crc;
            }
        }


        public Grades Grades
        {
            get
            {
                if (m_Grades == null)
                    m_Grades = new Grades(ref m_Data);
                return m_Grades;
            }
        }

        public Tests Tests
        {
            get
            {
                if (m_Tests == null)
                    m_Tests = new Tests(ref m_Data);
                return m_Tests;
            }
        }


        public Subjects Subjects
        {
            get
            {
                if (m_Subjects == null)
                    m_Subjects = new Subjects(ref m_Data);
                return m_Subjects;
            }
        }


        public User User
        {
            get
            {
                if (m_User == null)
                    m_User = new User(ref m_Data);
                return m_User;
            }
        }

        public Periods Periods
        {
            get
            {
                if (m_Periods == null)
                    m_Periods = new Periods(ref m_Data);
                return m_Periods;
            }
        }

        public WorkAreas WorkAreas
        {
            get
            {
                if (m_WorkAreas == null)
                    m_WorkAreas = new WorkAreas(ref m_Data);
                return m_WorkAreas;
            }
        }


        public Classes Classes
        {
            get
            {
                if (m_Classes == null)
                    m_Classes = new Classes(ref m_Data);
                return m_Classes;
            }
        }

        /*
        public Data Data
        {
            get
            {
                if (m_Data == null)
                    m_Data = new Data();
                return m_Data;
            }
        }
         * */

        public Students Students
        {
            get
            {
                if (m_Students == null)
                    m_Students = new Students(ref m_Data);
                return m_Students;
            }
        }

        public Event Event
        {
            get
            {
                if (m_Event == null)
                    m_Event = new Event();
                return m_Event;
            }
        }

        public XPathDocument XpathDoc
        {
            get
            {
                if (m_oXpathDoc == null)
                    m_oXpathDoc = this.xml.LoadXPathFile(@"..\..\config.xml");
                return m_oXpathDoc;
            }
        }
        public XPathDocument XpathLangDoc
        {
            get
            {
                if (m_oXpathLangDoc == null)
                    m_oXpathLangDoc = this.xml.LoadXPathFile(@"..\..\text.xml");
                return m_oXpathLangDoc;
            }
        }


        public xml xml
        {
            get
            {
                if (m_Xml == null)
                    m_Xml = new xml();
                return m_Xml;
            }
        }
    }
}
